import requests

def get_routes_info(origin, destinations, api_key):
    routes_info = {}
    base_url = "https://restapi.amap.com/v3/direction/driving"

    for destination in destinations:
        params = {
            'key': api_key,
            'origin': origin,
            'destination': destination,
            'strategy': '10',  # 多路径策略
            'output': 'json'
        }

        try:
            response = requests.get(base_url, params=params)
            response.raise_for_status()  # 如果请求失败，将抛出HTTPError异常
            result = response.json()

            if result['status'] == '1' and 'route' in result:
                paths = result['route']['paths']
                route_count = len(paths)
                min_distance = min(path['distance'] for path in paths) if paths else 0
                routes_info[destination] = {'route_count': route_count, 'min_distance': min_distance}
            else:
                print(f"API 请求失败，目的地 {destination}: {result.get('info', '未知错误')}")
        except requests.exceptions.RequestException as e:
            print(f"请求失败，目的地 {destination}，错误：{e}")

    return routes_info

# 使用示例
api_key = '	4df47f3c500b855652be703ef5fc1a4f'  # 使用您的API Key
origin = '114.277158,30.592578'
destinations = [
'114.283999,30.580196',
'114.292423,30.596650',
'114.291073,30.585646',
'114.292713,30.588973',
'114.267651,30.592817',
'114.273015,30.600042',
'114.287163,30.593047',
'114.287521,30.591133',
'114.277461,30.601832',
'114.286364,30.597694',
'114.286836,30.597207',
'114.266147,30.589399',
'114.266061,30.589276',
'114.267638,30.585831',
'114.281782,30.582693',
'114.289733,30.594159',
'114.273800,30.603134',
'114.289553,30.595947',
'114.282058,30.582049',
'114.282807,30.582267',
'114.274715,30.581319',
'114.273814,30.603745',
'114.271004,30.603001',
'114.290174,30.589020',
'114.288007,30.599844',
'114.284050,30.582313',
'114.290925,30.591648',
'114.264630,30.597587',
'114.283002,30.581747',
'114.276286,30.591012',
'114.274853,30.591239',
'114.277998,30.590115',
'114.276726,30.595661',
'114.277879,30.589474',
'114.273483,30.593228',
'114.276756,30.588540',
'114.280217,30.595978',
'114.277291,30.588265',
'114.272032,30.593657',
'114.277200,30.597572',
'114.271574,30.593994',
'114.276551,30.597574',
'114.271491,30.594132',
'114.279980,30.587836',
'114.282372,30.588815',
'114.283275,30.595674',
'114.270578,30.595157',
'114.269966,30.591105',
'114.283449,30.589183',
'114.269700,30.591300',
'114.270015,30.594929',
'114.268576,30.592237',
'114.285531,30.594489',
'114.281594,30.585954',
'114.258361,30.586910',
'114.257145,30.590174',
'114.257082,30.590233',
'114.262673,30.604595',
'114.267875,30.578485',
'114.258727,30.584514',
'114.264061,30.605810',
'114.256289,30.587866',
'114.256111,30.587592',
'114.262822,30.606014',
'114.267316,30.577228',
'114.257442,30.583271',
'114.258530,30.581591',
'114.274835,30.610550',
'114.270327,30.610883',
'114.268950,30.611457',
'114.278209,30.611471',
'114.280864,30.610731',
'114.263570,30.609800',
'114.268137,30.581178',
'114.285801,30.609183',
'114.276950,30.612803',
'114.260368,30.608623',
'114.273358,30.613412',
'114.284327,30.610954',
'114.288338,30.585220',
'114.255131,30.603690',
'114.263480,30.611760',
'114.274864,30.614094',
'114.285859,30.610674',
'114.289809,30.607732',
'114.289955,30.607635',

]  # 您的目的地列表

routes_info = get_routes_info(origin, destinations, api_key)
for dest, info in routes_info.items():
    print(f"目的地: {dest}, 路径数量: {info['route_count']}, 最短路径距离: {info['min_distance']}米")